GmailApp.sendEmail()函數的基本用法:
GmailApp.sendEmail(recipient, subject, body, options);
function sendEmailExample() {
var recipient = "recipient@example.com";
var subject = "这是邮件主题";
var body = "这是邮件正文内容。";
var options = {
cc: "cc@example.com",
bcc: "bcc@example.com",
name: "Your Name",
attachments: [
{ fileName: "attachment.txt", content: "这是附件的内容。" }
]
};
GmailApp.sendEmail(recipient, subject, body, options);
}
請注意,要使用GmailApp.sendEmail()函數,您需要在 Google Apps 腳本專案中啟用 Gmail API 服務。另外,如果您打算在腳本中傳送電子郵件,請確保您的腳本足夠具有執行此操作的權限,通常需要授權存取您的Gmail 帳戶。